//Name:
//Purpose:
//Author: wjy
//Date: 2022-01-14 17:18:20
//From:

#include <stdio.h>
#include <stdlib.h>

#define true 1

int main(void)
{
    int year, month, day;
    int min_year, min_month, min_day;
    int first = 1;
    while (true)
    {
        printf("Enter a date (mm/dd/yy): ");
        scanf("%d/%d/%d", &month, &day, &year);
        if (month == 0 && day == 0 && year == 0)
        {
            break;
        }
        else
        {
            if (first == 1)
            {
                min_day = day;
                min_month = month;
                min_year = year;
                first = 0;
            }
            else
            {
                if (year < min_year)
                {
                    min_day = day;
                    min_month = month;
                    min_year = year;
                }
                if (year == min_year)
                {
                    if (month < min_month)
                    {
                        min_day = day;
                        min_month = month;
                        min_year = year;
                    }
                    if (month == min_month)
                    {
                        if (day < min_day)
                        {
                            min_day = day;
                            min_month = month;
                            min_year = year;
                        }
                    }
                }
            }
        }
    }
    printf("%d/%d/%.2d is earliest date\n", min_month, min_day, min_year);
    system("pause");
    return 0;
}